<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>登陆</title>
<script src="http://localhost:8080/CourseSupport/js/jquery-1.11.3.min.js" ></script>
</head>
<body>
<center>登陆用户</center><br>
<center>
<form >
	工号:<input name="userCode" id="userCode" type="text" value="2014303326"/><br>
	密码:<input name="password" id="password"  type="password" value="admin"/><br>
	<label><input name="type" type="radio" value="1" checked="checked"/>学生</label> 
	<label><input name="type" type="radio" value="2" />助教</label> 
	<label><input name="type" type="radio" value="3" />老师</label> <br>
</form>
<button onclick="login()">登录</button>
</center>
</body>
<script>
var login=function(){
	var userCode =$("#userCode").val();
	var password =$("#password").val();
	var type =$("input[name='type']:checked").val();
	 var json={
			 userCode:userCode,
			 password:password,
			 type:type
	 }
	 
	 $.ajax({ 
         type:"POST", 
         url:"http://localhost:8080/CourseSupport/user/login", 
         dataType:"json",      
         contentType:"application/json",               
         data:JSON.stringify(json), 
         success:function(data){ 
        	 if(data.status=="succsss"){
          		  alert(data.status);
          		window.location.href="user/welcome";
          	  }else{
          		  alert(data.status);
          	  }
         } 
      }); 
}
</script>
</html>